package com.xxl.controller;

import org.springframework.beans.propertyeditors.StringTrimmerEditor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * 路由
 *
 * @author xxl
 * @date 2023/3/14
 */
@Controller
@RequestMapping("view")
public class RouteController {

    @Resource
    HttpServletRequest request;

    /**
     * 去往等级页面
     */
    @GetMapping("/common.html/{text}")
    public String toLevelPage(@PathVariable("text") String text,Model model) {
        System.out.println(model.getAttribute("ModelAttribute1"));
        request.setAttribute("msg", text);
        return "/common/common";
    }

    /**
     * 去往登录页面
     */
    @PostMapping("/login")
    public String toLoginPage1() {
        return "/view/login";
    }

    @GetMapping("/login.html")
    public String toLoginPage2(String name) {
        return "/view/login.html";
    }

    /**
     * 去往未授权页面
     */
    @GetMapping("/unauthorized.html")
    public String unauthorized() {
        return "/view/unauthorized.html";
    }


}
